"""update employee model

Revision ID: update_employee_model
Revises: previous_revision
Create Date: 2024-03-21

"""
from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = 'update_employee_model'
down_revision = 'previous_revision'
branch_labels = None
depends_on = None

def upgrade():
    # 添加skills字段到employee表
    op.add_column('employee', sa.Column('skills', sa.Text(), nullable=True))
    
    # 删除skills表
    op.drop_table('skill')

def downgrade():
    # 创建skills表
    op.create_table('skill',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('employee_id', sa.Integer(), nullable=False),
        sa.Column('name', sa.String(length=100), nullable=False),
        sa.Column('level', sa.String(length=50), nullable=True),
        sa.Column('proficiency', sa.String(length=50), nullable=True),
        sa.Column('years_of_experience', sa.Integer(), nullable=True),
        sa.Column('description', sa.Text(), nullable=True),
        sa.ForeignKeyConstraint(['employee_id'], ['employee.id'], ),
        sa.PrimaryKeyConstraint('id')
    )
    
    # 删除employee表中的skills字段
    op.drop_column('employee', 'skills') 